﻿using System.Windows;

namespace compshop.Modules.Categories.Views
{
    /// <summary>
    /// Interaction logic for AddCategoryDialog.xaml
    /// </summary>
    public partial class AddCategoryDialog : Window
    {
        private bool? isCategory;

        public AddCategoryDialog(bool? isCategory)
        {
            InitializeComponent();

            this.isCategory = isCategory;
            if (isCategory==false)
            {
                lblCategory.Visibility = Visibility.Visible;
                comboxCategory.Visibility = Visibility.Visible;
                lblNewCategory.Content = Resource.NewSubCategory;
            }
            else
                if (isCategory == null)
                {
                    lblNewCategory.Content = Resource.Edit;
                }
        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tboxNewCategory.Text))
            {
                MessageBox.Show(Resource.NoName);
                return;    
            }

            if (comboxCategory.Visibility == Visibility.Visible && comboxCategory.SelectedItem == null)
            {
                MessageBox.Show(Resource.NoCategory);
                return;    
            }
           
            DialogResult = true;
            Close();
        }
    }
}


